package com.example.demo.study;

import java.util.ArrayList;
import java.util.Collections;

public class Study09 {
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>();
        list.add("good");
        list.add("study");
        list.add("day");
        System.out.println(list); // [good, study, day]
        System.out.println(list.get(1)); // study
        list.set(1, "code");
        System.out.println(list); // [good, code, day]
        list.remove(1);
        System.out.println(list); // [good, day]
        System.out.println(list.size()); // 2
        for (int i = 0; i < list.size(); i++) {
            System.out.println("手环"+list.get(i));
        }
        for (String x:list) {
            System.out.println("手环2"+x);
        }
        System.out.println("-------------------------");

        ArrayList<Integer> numbers = new ArrayList<>();
        numbers.add(10);
        numbers.add(2);
        numbers.add(3);
        System.out.println(numbers); // [1, 2, 3]
        // 排序
        Collections.sort(numbers);
        System.out.println(numbers); // [1, 2, 3]
        numbers.clear();
        System.out.println(numbers); // []

    }
}
